import Vue from 'vue';
import App from './App';
import router from './router';
import axios from 'axios';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'; // 默认主题
import "babel-polyfill";

Vue.use(ElementUI, { size: 'small' });
Vue.prototype.$axios = axios;

import comPlugIn from './views/common/comPlugIn.js';
Vue.prototype.$comPlugIn = comPlugIn;

Vue.prototype.$getWords = function(index){
    let user = localStorage.getItem('zhdq_words');
    var jsonObj = JSON.parse(user)?JSON.parse(user).words:'';
    for (let i in jsonObj) {
        if (index != undefined) {
            if (i == index) {
                return jsonObj[i].items
            }
        } else {
            return []
        }
    }
} 

let vm = new Vue({
    router,
    render: h => h(App)
}).$mount('#app');
window.$vm = vm;
router.beforeEach((to, from, next) => {
    window.scrollTo(0, 0);
    next();
})